package cn.edu.ncu.housinghub.dto.request.house;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
public class HouseConditionRequest {
    @NotBlank(message = "省份不能为空")
    private String province;
    @NotBlank(message = "城市不能为空")
    private String city;
    private String district;
    //户型
    private Integer layout;
    //租金范围
    @Min(value = 0, message = "最小租金必须大于0")
    private Integer rentMin;
    @Max(value = 10000, message = "最大租金必须小于10000")
    private Integer rentMax;
    //最小租金不能大于最大租金
    public boolean isValidRentRange() {
        return rentMin <= rentMax;
    }

    //朝向
    private String orientation;

    //房屋代理方式
    @Min(value = 0, message = "房东直租")
    @Max(value = 1, message = "中介代理")
    private Integer houseRentType;

    // 面积范围
    @Min(value = 0, message = "最小面积必须大于等于0")
    private Integer areaMin;

    @Max(value = 1000, message = "最大面积必须小于等于1000")
    private Integer areaMax;

    // 最小面积不能大于最大面积
    public boolean isValidAreaRange() {
        return areaMin == null || areaMax == null || areaMin <= areaMax;
    }
}
